home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_edit.arc / ED5.C < prev    next >
C/C++ Source or Header  |  1991-09-08  |  2KB  |  158 lines

  1. /* ED5.C */
  2.  
  3. #include "ed0.c"
  4. #include "ed1.ccc"
  5. int fmtrev;
  6. int fmttab;
  7. int fmtdev;
  8. int fmtwidth;
  9. int fmtcol[MAXLEN1];
  10. tablength()  
  11. {
  12.     return(fmttab);
  13. }
  14. fmtytab()
  15. {
  16.     fmtrev=YES;
  17. }
  18. fmtntab()
  19. {
  20.     fmtrev=NO;
  21. }
  22. fmtassn(listflag) int listflag;
  23. {
  24.     if (listflag==YES) {
  25.         fmtdev=YES;
  26.         fmtwidth=LISTW;
  27.     }
  28.     else {
  29.         fmtdev=NO;
  30.         fmtwidth=SCRNW1;
  31.     }
  32. }
  33. fmtadj(buf,minind,maxind) char *buf; int minind,maxind;
  34. {
  35. int k;
  36.     fmtcol[0]=0;
  37.     k=minind;
  38.     while (k<maxind) {
  39.         if (buf[k]==CR) {
  40.             break;
  41.         }
  42.         fmtcol[k+1]=fmtcol[k]+fmtchlen(buf[k],fmtcol[k]);
  43.         k++;
  44.     }
  45. }
  46. fmtlen(buf,i) char *buf; int i;
  47. {
  48.     return(fmtcol[i]);
  49. }
  50. fmtsubs(buf,i,j) char *buf; int i,j;
  51. {
  52. int k;
  53.     if (fmtcol[i]>=fmtwidth) {
  54.         return;
  55.     }
  56.     outxy(fmtcol[i],outyget());
  57.     while (i<j) {
  58.         if (buf[i]==CR) {
  59.             break;
  60.         }
  61.         if (fmtcol[i+1]>fmtwidth) {
  62.             break;
  63.         }
  64.         fmtoutch(buf[i],fmtcol[i]);
  65.         i++;
  66.     }
  67.     if (fmtcol[i]<SCRNW1) {    /* modified to allow full screen width */
  68.     outdeol();
  69.     }
  70. }
  71. fmtsout(buf,offset) char *buf; int offset;
  72. {
  73. char c;
  74. int col,k;
  75.     col=0;
  76.     while (c= *buf++) {
  77.         if (c==CR) {
  78.             break;
  79.         }
  80.         k=fmtchlen(c,col);
  81.         if ((col+k+offset)>fmtwidth) {
  82.             break;
  83.         }
  84.         fmtoutch(c,col);
  85.         col=col+k;
  86.     }
  87.     return(col);        /* fmtsout() now returns column value */
  88. }
  89. fmtchlen(c,col) char c; int col;
  90. {
  91.     if (c==TAB) {
  92.         return(fmttab-(col%fmttab));
  93.     }
  94.     else if ((c<32)&(fmtdev==NO)) {
  95.         return(2);
  96.     }
  97.     else {
  98.         return(1);
  99.     }
  100. }
  101. fmtoutch(c,col) char c; int col;
  102. {
  103. int k;
  104.     if (c==TAB) {
  105.         k=fmtchlen(TAB,col);
  106.         if ((fmtdev==NO)&(fmtrev==YES)) {
  107. /*show tab characters in reverse video */
  108.             scr_chr_attr(SETREVERSE);
  109.         }
  110.         while ((k--)>0) {
  111.             fmtchdev(' ');
  112.         }
  113.         if ((fmtdev==NO)&(fmtrev==YES)) {
  114.             scr_chr_attr(SETNORMAL);
  115.         }
  116.     }
  117.     else if (c<32) {
  118. /* show control characters in reverse video */
  119.         if (fmtdev==NO) {
  120.             scr_chr_attr(SETREVERSE);
  121.             fmtchdev(c+64);
  122.             scr_chr_attr(SETNORMAL);
  123.         }
  124.         else {
  125.             fmtchdev('^');
  126.             fmtchdev(c+64);
  127.         }
  128.     }
  129.     else {
  130.         fmtchdev(c);
  131.     }
  132. }
  133. fmtchdev(c) char c;
  134. {
  135.     if (fmtdev==YES) {
  136.         syslout(c);
  137.     }
  138.     else {
  139.         outchar(c);
  140.     }
  141. }
  142. fmtcrlf()
  143. {
  144.     if (fmtdev==YES) {
  145.         syslout(CR);
  146.         syslout(LF);
  147.     }
  148.     else {
  149.         outxy(0,SCRNL1);
  150.         syscout(CR);
  151.         syscout(LF);
  152.     }
  153. }
  154. fmtset(n) int n;
  155. {
  156.     fmttab=max(1,n);
  157. }
  158.